#!/bin/bash

clear 
echo -e "\033[31m******欢迎购买福彩双色球******\033[0m"
hongqiu=($(seq -s " " 1 32)) 
echo "红球:" 
echo ${hongqiu[@]}
lanqiu=($(seq -s " " 1 16)) 
echo "蓝球:"
echo ${lanqiu[@]} 

for i in  $(seq 6)
do
	ran1=$((RANDOM%${#hongqiu[@]}))
	hq[x++]=${hongqiu[ran1]} 
	unset hongqiu[ran1]
	hongqiu=(${hongqiu[@]})
done 

ran2=$((RANDOM % 16 )) 
lq=${lanqiu[ran2]}

echo -e "这期福彩双色球的中奖号码是：\033[33m***\033[0m红球：\033[31m${hq[@]}\033[0m 蓝球:\033[34m$lq\033[33m***\033[0m"
k=0
while true
do
	read -p "请从1-32中选择六个红球号码：" red1 red2 red3 red4 red5 red6
	 #(( $# == 6 )) ||(echo "the number is lesser than 6,please try again!";exit)
	
	read -p "请从1-16中选择一个蓝球号码：" blue1
	(( k++ ))
	if (( $blue1 != $lq ))
	then
		echo "太可惜了，你没有中奖，您已购买$k次，欢迎再次购买！"
	else
		echo "$red1 $red2 $red3 $red4 $red5 $red6" >1.txt
		echo "${hq[@]}" >2.txt
		if cat 2.txt|grep $red1|grep $red2|grep $red3|grep $red4|grep $red5|grep $red6 &>/dev/null
		then
			echo "恭喜您，获得500万大奖"
			break
		else
			echo "太可惜了，你没有中奖"
			echo "您已购买$k次，欢迎再次购买"
		fi
	fi

done
for i in {5..1}
do
      	echo -e "$i";sleep 1
done

echo -e "这期福彩双色球的中奖号码是：\033[33m***\033[0m红球：\033[31m${hq[@]}\033[0m 蓝球：\033[34m$lq\033[33m***\033[0m"

